package day07;

import java.util.Scanner;

public class CalAirPrice {
    public static void main(String[] args) {
        while (true){
        Scanner scan = new Scanner(System.in);
        System.out.println("请输入机票价格");
        double price = scan.nextDouble();

        System.out.println("请输入月份(1-12)");
        int month =scan.nextInt();

            if (month<1 || month>12) {
            System.out.println("输入有误");
            continue;
        }

            System.out.println("请选择机票类型 1.头等舱 2.商务舱 3.经济舱");
            int command = scan.nextInt();

            if (command>3 || command<1){
                System.out.println("输入有误");
                continue;
            }

            double finalprice = CalAirPrice(price, month, command);
            System.out.println("机票价格为：" + finalprice + "元");
        }
    }

    public static double CalAirPrice(double price,int month,int command){
        double finalprice = 0.0;



            if(month>=5 && month <=10){
                switch (command){
                    case 1:
                        finalprice = price*0.9;
                        break;
                    case 2:
                        finalprice = price*0.85;
                        break;
                    case 3:
                        finalprice = price*0.8;
                        break;
                    default:
                        System.out.println("信息输入有误");
                }
            }else if(month<=4 || month >=10){
                switch (command){
                    case 1:
                        finalprice = price*0.7;
                        break;
                    case 2:
                        finalprice = price*0.65;
                        break;
                    case 3:
                        finalprice = price*0.6;
                        break;
                    default:
                        System.out.println("信息输入有误");
                }
            }

        return finalprice;
    }
}
